const {
  devBaseUrl,
  isDevProxy
} = require('./config')

const vueCliConfig = {
  devServer: {
    // 请先了解代理逻辑，再设置前端代理
    // 这里配置了跨域及代理只针对开发环境生效
    proxy: {
      '/api': {
        target: devBaseUrl,
        ws: true,
        changeOrigin: true,
        pathRewrite: {
          ['^/api']: '',
        },
      },
    }
  },
}

if (!isDevProxy) {
  delete vueCliConfig.devServer.proxy
}

module.exports = vueCliConfig